<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>综合服务 评分列表页</title>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <!--页面样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/style.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--页面样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--JQ-->
    <script type="text/javascript" charset="utf-8"
            src="${re.contextPath}/plugin/common/js/jquery-1.8.3.min.js"></script>
    <!--Layui-->
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
    <!--公用样式JS-->
    <script type="text/javascript" src="${re.contextPath}/plugin/common/js/comment.js" charset="utf-8"></script>
    <style>
        .layui-laypage-limits>select{
            width: 100% !important;
        }
        .layui-btn-normal {
            background: #5775EF;
        }
    </style>
</head>

<body>

<div style="background-color: #F1F4FB;padding-left: 20px;">
    <span class="layui-breadcrumb" lay-separator=">">
        <a><cite>考试管理</cite></a>
        <a href="/exam/list/index"><cite>考试列表</cite></a>
        <a href="#"><cite>评分</cite></a>
    </span>
</div>

<!--容器-->
<div class="container index clearfix">
    <!--右侧内容-->
    <div class="Right fr" style="width: 100%;">
        <div  lay-filter="docDemoTabBrief">
            <div style="background-color: #F1F4FB;border-radius: 5px;padding:14px 10px;">
                <div class="layui-row">
                    <div class="layui-col-md4" style="padding-left:1%">
                        <input type="hidden" id="examId" name="examId" value="${examId}">
                        <input id="userName" class="layui-input layui-input-inline" type="text" placeholder="请输入姓名搜索" style="width: 40%">
                        <input class="layui-btn layui-btn-normal" type="button" style="" value="筛选" onclick="query()">
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<div class="layui-container"
     style="background-color: #ffffff;width:96%;padding:16px;border-radius: 10px">
    <div style="width: 100%;text-align: right">
        <button type="button" class="layui-btn layui-btn-normal white ft18 close" onclick="returns()">返回</button>
        <button type="button" class="layui-btn layui-btn-normal white ft18 close" onclick="derive()">导出</button>
        <button type="button" lay-submit class="layui-btn layui-btn-normal bluebg white ft18 " onclick="reset()">批量重置</button>
    </div>
    <div class="layui-row" style="width: 100%;text-align: center">
        <table id="tableList" class="layui-hide" lay-filter="tableList"></table>
    </div>

</div>
<script type="text/javascript" src="${re.contextPath}/pageoffice.js" id="po_js_main"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/html" id="toolBar">
    <a class="layui-btn layui-btn-xs  layui-btn-normal" lay-event="pf">评分</a>
    <a class="layui-btn layui-btn-xs  layui-btn-normal" lay-event="czpf">重置评分</a>
    <a class="layui-btn layui-btn-xs  layui-btn-normal" lay-event="del">删除</a>
</script>
<script>
    var layer;
    var tableIns;
    var table= null;
    $(function () {
        layui.use(['table', 'element'], function () {
            table = layui.table;
            //方法级渲染
            tableIns = table.render({
                id: 'tableList',
                elem: '#tableList',
                url: '/give/mark/selectExamList?examId='+$("#examId").val(),
                height: 'full-230',
                page: true,
                cols: [[
                    {type:'checkbox'},
                    {
                        title: '序号', width: '7%', templet: function (res) {
                            return res.LAY_INDEX;
                        }
                    },
                    {field: 'stuExamId', title: 'ID', hide: true, sort: false},
                    {field: 'paperId', title: 'paperId', hide: true, sort: false},
                    {field: 'examId', title: 'examId', hide: true, sort: false},
                    {field: 'examName', title: '考试名称', width: '10%', sort: false},
                    {field: 'userName', title: '考生姓名', width: '10%', sort: false},
                    {field: 'deptName', title: '部门', width: '10%', sort: false},
                    {field: 'score', title: '考试得分', width: '7%', sort: false},
                    {field: 'passScore', title: '及格分', width: '5%', sort: false},
                    {field: 'isJg', title: '是否及格', width: '7%',templet: function (d) {
                            if (d.isJg == "1") {
                                return '<span >是</span>'
                            }else if (d.isJg == "0") {
                                return '<span >否</span>'
                            }else {
                                return  '<span></span>'
                            }
                        }},
                    {field: 'isMark', title: '评分状态', width: '7%',templet: function (d) {
                        if (d.isMark == "0") {
                            return '<span >未评分 </span>'
                        }else if (d.isMark == "1") {
                            return '<span >已评分</span>'
                        }else{
                            return '<span ></span>'
                        }
                    }},
                    {field: 'startTime', title: '答卷开始时间', width: '12%', sort: false},
                    {field: 'submitTime', title: '答卷结束时间', width: '12%', sort: false},
                    {field: 'remark', title: '操作', width: '13%', toolbar: "#toolBar"}
                ]],
            });

            table.on('tool(tableList)', function (obj) {
                var data = obj.data;
                if (obj.event === 'pf') {
                    pf(data);
                }
                if (obj.event === 'czpf') {
                    czpf(data);
                }
                if (obj.event === 'del') {
                    del(data.stuExamId);
                }
            });
        })
    })

    //筛选
    function query() {
        var userName = $('#userName').val();
        jsondata = {
            userName: userName
        };
        table.reload('tableList', {where: jsondata});
    }

    //评分
    function pf(data){
        if("1"==data.isMark){
            layer.msg("已评分不可重复评分!",{icon:2});return false;
        }
        var type = "auto";
        var w = "70%";
        var h = "90%";
        url = "/give/mark/giveAMark?stuExamId="+data.stuExamId+"&paperId="+data.paperId+"&examId="+data.examId;
        layer.open({
            id: 'form-add',
            type: 2,
            area: [w, h],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: "评分",
            content: url,
            end: function () {
                tableIns.reload();
            }
        });
    }

    //重置评分
    function czpf(data){
        if("0"==data.isMark){
            layer.msg("未评分不用重置!",{icon:2});return false;
        }
        layer.confirm('是否对当前数据进行重置评分?', {btn: ['确定', '取消']}, function () {
            layerAjaxGet("/give/mark/updateReset",{ids:data.stuExamId},"",function (d) {
                if(d){
                    layer.msg("操作成功！",{icon:1});
                    var index = parent.layer.getFrameIndex(window.name);
                    layer.close(index);
                    tableIns.reload();
                }else{
                    layer.msg("操作失败！",{icon:2})
                }
            })
        })
    }

    //删除
    function del(stuExamId){
        layer.confirm('确定要删除吗?', {btn: ['确定', '取消']}, function () {
            layerAjaxGet("/give/mark/updateDel",{stuExamId:stuExamId},"",function (d) {
                if(d){
                    layer.msg("操作成功！",{icon:1});
                    var index = parent.layer.getFrameIndex(window.name);
                    layer.close(index);
                    tableIns.reload();
                }else{
                    layer.msg("操作失败！",{icon:2})
                }
            })
        })
    }

    //批量重置
    function reset(){
        var datas = table.checkStatus('tableList').data;
        if(datas.length==0){
            layer.msg("至少选择一个",{icon:2});return false;
        }
        var ids=[];
        for(let i=0;i<datas.length;i++){
            ids.push(datas[i].stuExamId);
            if("0"==datas[i].isMark){
                layer.msg("未评分不用重置!",{icon:2});return false;
            }
        }
        layer.confirm('是否对当前数据进行重置评分?', {btn: ['确定', '取消']}, function () {
            layerAjaxGet("/give/mark/updateReset",{ids:ids},"",function (d) {
                if(d){
                    layer.msg("操作成功！",{icon:1});
                    let index = parent.layer.getFrameIndex(window.name);
                    layer.close(index);
                    tableIns.reload();
                }else{
                    layer.msg("操作失败！",{icon:2})
                }
            })
        })
    }

    function derive(){
        var datas = table.checkStatus('tableList').data;
        if(datas.length==0){
            layer.msg("至少选择一个",{icon:2});return false;
        }
        var ids=[];
        for(let i=0;i<datas.length;i++){
            ids.push(datas[i].examId);
        }
        var url= '/give/mark/export?ids='+ids;
        location.href = url;
    }

    function returns(){
        window.parent._showtab('e0652f5faea74175be94ebf0d2a41dd6', '考试列表', '/exam/list/index');
    }

</script>
</body>
</html>
